<template>
    <div class="Set">
        <div class="Nav">
            <van-icon name="arrow-left" @click="exit()" />
            <div class="title">设置</div>
        </div>
        <div class="exit" @click="exitLogin" v-if="isLogined">退出登录</div>
    </div>
</template>

<script>
export default {
    name: "Set",
    data() {
        return {
            isLogined: null,
        };
    },
    created() {
        // 获取登录状态
        this.isLogined = JSON.parse(localStorage.getItem("isLogined"));
    },
    methods: {
        // 退出登录
        exitLogin() {
            // 修改登录成功标识符
            localStorage.setItem("isLogined", false);
            // 返回用户界面
            this.$router.push({ name: "My" });
        },
        exit() {
            this.$router.back();
        },
    },
};
</script>

<style lang="less" scoped>
.exit {
    width: 200px;
    height: 40px;
    background-color: green;
    margin: 200px auto;
    font-size: 20px;
    line-height: 40px;
    text-align: center;
    color: #fff;
}
.Nav {
    height: 50px;
    display: flex;
    align-items: center;
    .van-icon-arrow-left {
        margin: 0 140px 0 15px;
        font-size: 20px;
    }
    .title {
        font-size: 16px;
    }
}
</style>
